package pta.newch04.ex23;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner  scanner = new Scanner(System.in);
        Square s1 = new Square();
        System.out.println("s1:edge=" + s1.getEdge());
        System.out.println("s1:area=" + s1.getArea());
        Square s2 = new Square();
        int edgeValue = scanner.nextInt();
        s2.setEdge(edgeValue);
        System.out.println("s2:edge=" + s2.getEdge());
        System.out.println("s2:area=" + s2.getArea());
        scanner.close();
    }
}
class Square {
    private int edge;
    public Square() {
        this.edge = 2;
        System.out.println("this is constructor method");
    }
    public void setEdge(int edge) {
        if (edge <= 0) {
            this.edge = 1;
        } else {
            this.edge = edge;
        }
    }
    public int getEdge() {
        return this.edge;
    }
    public int getArea() {
        return this.edge * this.edge;
    }
}